package com.j180.mybatisplus_2demo.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.j180.mybatisplus_2demo.bean.StudentBean;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface IStudentDao extends BaseMapper<StudentBean> {

    @Insert("insert into t_student values(null,#{name},#{gender},#{age},#{classBean.id})")
    public int addStudent(StudentBean studentBean);
   /* @Select(" select \n" +
            "       stu.id as stuId,\n" +
            "       stu.name as stuName,\n" +
            "       stu.gender as stuGender,\n" +
            "       stu.age as stuAge,\n" +
            "       cls.id as clsId,\n" +
            "       cls.name as clsName  \n" +
            "       from t_student as stu left join t_class as cls on stu.classsId = cls.id ${ew.customSqlSegment}")*/
      //@Param(Constants.WRAPPER)
    //@ResultMap("resultMaps.stuMap")
    //public IPage<StudentBean> getAllStudents(IPage<StudentBean> page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper);

    public IPage<StudentBean> getAllStudents(IPage<StudentBean> page, QueryWrapper ew);

}
